package com.xinruke.hostels.central.manage.controller;

import com.xinruke.hostels.central.manage.interfaces.dto.*;
import com.xinruke.hostels.central.manage.service.OrganizationService;
import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName OrganizationController
 * @CreateDate 2019/6/13
 * @Author FengXinQiang
 * @Version V1.0.0.0
 * @Decription 组织架构
 */
@RestController
@RequestMapping("organization/")
@Api(tags = "组织架构")
public class OrganizationController extends BaseController {

    @Resource
    private OrganizationService orgService;

    @PostMapping("add")
    @ApiOperation(value = "添加组织架构")
    public ResultVO addOrganization(@RequestBody OrganizationAddDTO organizationAddDTO) {
        return orgService.add(organizationAddDTO);
    }

    @PostMapping("modify")
    @ApiOperation(value = "修改组织架构")
    public ResultVO modifyOrganization(@RequestBody OrganizationModifyDTO organizationModifyDTO) {
        return orgService.modifyOrganization(organizationModifyDTO);
    }

    @PostMapping("delete")
    @ApiOperation(value = "删除组织架构")
    public ResultVO deleteOrganization(@RequestBody OrganizationDeleteDTO organizationDeleteDTO) {
        return orgService.delete(organizationDeleteDTO);
    }

    @PostMapping("detail")
    @ApiOperation(value = "详情")
    public ResultVO<OrganizationDetailQueryResultDTO> detail(@RequestBody OrganizationDetailQueryDTO organizationQueryDTO) {
        return orgService.detail(organizationQueryDTO);
    }

    @PostMapping("tree")
    @ApiOperation(value = "查询组织树")
    public ResultVO<List<OrganizationQueryResultDTO>> getorganizationTree(@RequestBody OrganizationQueryDTO organizationQueryDTO) {
        return orgService.getorganizationTree(organizationQueryDTO);
    }
}
